function getModelStr(moduleName) {
	const Name = moduleName.substr(0, 1).toUpperCase() + moduleName.substring(1);
	let str = `!
	<template>
		<el-dialog v-model="dialogVisible" :title="dialogProps.title" :destroy-on-close="true" size="450px">
			<el-form
				ref="formRef"
				:model="dialogProps.rowData"
				label-width="100px"
				label-suffix=" :"
				:rules="rules"
				:disabled="dialogProps.onlyRead"
				:hide-required-asterisk="dialogProps.onlyRead"
			>
			</el-form>
			<el-form-item label="歌名" prop="${moduleName}">
				<el-input type="text" v-model="dialogProps.rowData.${moduleName}" placeholder="请填写" />
			</el-form-item>
			<template #footer>
				<span class="dialog-footer">
					<el-button @click="dialogVisible = false">取 消</el-button>
					<el-button v-if="!dialogProps.onlyRead" type="primary" @click="save">保 存</el-button>
				</span>
			</template>
		</el-dialog>
	</template>
	
	<script setup lang="ts">
	import { create${Name}, update${Name}, get${Name}ById } from "@/api/modules/${moduleName}";
	import { ElMessage } from "element-plus";
	import { ref, reactive } from "vue";
	interface DialogProps {
		title: string;
		rowData?: any;
		onlyRead: boolean;
	}
	
	const emit = defineEmits(["edited"]);
	
	const formRef = ref();
	const dialogVisible = ref(false);
	const dialogProps = ref<DialogProps>({
		title: "",
		onlyRead: false
	});
	
	// 表单校验规则
	const rules = reactive({
		${moduleName}: [{ required: true, message: "请填写" }]
	});
	
	// 接收父组件传过来的参数
	const acceptParams = async (params: DialogProps): Promise<void> => {
		dialogProps.value = params;
		dialogVisible.value = true;
	
		// 需要查询详情这样写，如果直接用表格的数据可以去掉
		const detail = (await get${Name}ById(dialogProps.value.rowData.id)).data || null;
		if (detail) {
			dialogProps.value.rowData = detail;
		}
	};
	
	const save = () => {
		formRef.value!.validate(async (valid: any) => {
			if (!valid) return;
			try {
				if (dialogProps.value.title === "新增") {
					await create${Name}(dialogProps.value.rowData);
				} else {
					await update${Name}(dialogProps.value.rowData);
				}
				ElMessage.success({ message: dialogProps.value.title + "成功" });
				emit("edited");
				dialogVisible.value = false;
			} catch (error) {
				console.log(error);
			}
		});
	};
	
	defineExpose({
		acceptParams
	});
	</script>
	
	<style scoped></style>
	`;
	return str;
}

module.exports = getModelStr;
